﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AteneoLibriBusinessLogic.Entities;

namespace AteneoLibriBusinessLogic.TOA
{
    public class SaleAssembler
    {

        public static Sale Assembler(AteneoLibriEntityFramework.Sale item)
        {
            Sale s = new Sale();

            s.IdSale = item.IdSale;
            s.StartDate = item.StartDate;
            s.EndDate = item.EndDate;
            s.Price = item.Price;
            s.SaleStatusId = item.SaleStatusId;
            s.BookId = item.BookId;
            s.UserIdPurchaser = item.UserId;
            s.Description = item.Description;
            s.SoldTo = item.SoldTo;

            //s.EmailSeller = item.Book.User.Email;
            //s.UsernameSeller = item.Book.User.Username;

            return s;
        }

        public static AteneoLibriEntityFramework.Sale DeAssembler(Sale item)
        {
            AteneoLibriEntityFramework.Sale s = new AteneoLibriEntityFramework.Sale();

            s.IdSale = item.IdSale;
            s.StartDate = item.StartDate;
            s.EndDate = item.EndDate;
            s.Price = item.Price;
            s.SaleStatusId = item.SaleStatusId;
            s.BookId = item.BookId;
            s.UserId = item.UserIdPurchaser;
            s.Description = item.Description;
            s.SoldTo = item.SoldTo;

            return s;
        }

        public static void WriteToEntity(AteneoLibriEntityFramework.Sale entity, Sale item)
        {
            entity.IdSale = item.IdSale;
            entity.StartDate = item.StartDate;
            entity.EndDate = item.EndDate;
            entity.Price = item.Price;
            entity.SaleStatusId = item.SaleStatusId;
            entity.BookId = item.BookId;
            entity.UserId = item.UserIdPurchaser;
            entity.Description = item.Description;
            entity.SoldTo = item.SoldTo;
        }

    }
}
